package com.yn.pet.controller.pc;


import com.yn.common.core.domain.AjaxResult;
import com.yn.pet.controller.pc.biz.DeviceInfoBizService;
import com.yn.pet.controller.pc.request.DeviceInfoRequest;
import com.yn.pet.bus.entity.DeviceInfo;
import lombok.AllArgsConstructor;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.io.IOException;
import java.util.Set;

/**
 * 设备信息表(DeviceInfo)表控制层
 *
 * @author makejava
 * @since 2025-07-09 12:00:46
 */
//@Anonymous
@RestController
@AllArgsConstructor
@RequestMapping("/admin/deviceInfo")
public class DeviceInfoController {

    private final DeviceInfoBizService deviceInfoBizService;

    @GetMapping("pageList")
    public AjaxResult pageList(DeviceInfoRequest deviceInfoRequest) {
        return AjaxResult.success(deviceInfoBizService.pageList(deviceInfoRequest));
    }

    @PostMapping("saveDeviceInfo")
    public AjaxResult saveDeviceInfo(@RequestBody DeviceInfo deviceInfo) {
        deviceInfoBizService.saveDeviceInfo(deviceInfo);
        return AjaxResult.success();
    }

    @GetMapping("removeDeviceInfo")
    public AjaxResult removeDeviceInfo(@RequestParam Set<Long> deviceIdSet) {
        deviceInfoBizService.removeDeviceInfo(deviceIdSet);
        return AjaxResult.success();
    }

    @PostMapping("importDeviceInfo")
    public AjaxResult importDeviceInfo(MultipartFile file) throws IOException {
        return AjaxResult.success(deviceInfoBizService.importDeviceInfo(file));
    }
}

